-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Make sure we dispose CancellationTokenRegistration #2776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
85802bf
to
d66138b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - just one question on what should be included in the using block.
I don't think await GetResponseAsync(requestData, request, builder);
needs to be wrapped in the using
as cancellation of the request is handled by RegisterApmTaskTimeout()
|
||
if (data != null) | ||
var request = this.CreateHttpWebRequest(requestData); | ||
using (cancellationToken.Register(() => request.Abort())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this also need to include await GetResponseAsync(requestData, request, builder);
in the using block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right i think it does
@forloop updated with one more commit mind giving this another review? 👍 |
… single request, e.g bulkall/scrollall/reindex it will leak Register() handles and memory will keep on growing
…ely cancel on the waithandles in the case of exceptions too
47afefc
to
fd2cc93
Compare
* When the passed cancellation token is shared for a longer time then a single request, e.g bulkall/scrollall/reindex it will leak Register() handles and memory will keep on growing * PostRequestAsync does not need to be generic * include GetResponse() in using and inlined it so we can more aggresively cancel on the waithandles in the case of exceptions too
…hat now needs forward porting again to 5.x master cc @russcam
…e begin/end getrequeststream apm task wait handler relates to #2776
…e begin/end getrequeststream apm task wait handler relates to #2776
@russcam spotted an opportunity to clean up the code while manually merging to |
Nice! |
* When the passed cancellation token is shared for a longer time then a single request, e.g bulkall/scrollall/reindex it will leak Register() handles and memory will keep on growing * PostRequestAsync does not need to be generic * include GetResponse() in using and inlined it so we can more aggresively cancel on the waithandles in the case of exceptions too
…e begin/end getrequeststream apm task wait handler relates to elastic#2776
When the passed cancellation token is shared for a longer time then a single request, e.g bulkall/scrollall/reindex all spawn multiple requests over a single cancellationtoken it will leak Register() handles and memory will keep on growing because it will keep
requests
around indefinitely.